﻿//Show/Hide History
function ToggleTable(td)
{
	var minus = td.children[0];
	var plus  = td.children[1];
	var table = td.parentElement.parentElement.parentElement.nextSibling;
	var makeVisible = (minus.style.display == 'none');
	ShowHide(minus, makeVisible);
	ShowHide(plus, !makeVisible);
	ShowHide(table, makeVisible);
	document.location = '#history';
}
function ShowHide(obj, isVisible)
{	obj.style.display = (isVisible) ? '' : 'none'; }

//Better textarea
function SupportTabKey(txt)
{
	if (9 != event.keyCode)
		return true;
	InsertAtCursor(txt, String.fromCharCode(event.keyCode));
	return false;
}
function SupportEnterKey(txt)
{
	InsertAtCursor(txt, String.fromCharCode(event.keyCode));
	return false;
}
function InsertAtCursor(myField, myValue) 
{
	//IE support
	if (document.selection) 
	{
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') 
	{
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue
		+ myField.value.substring(endPos, myField.value.length);
	} 
	else 
	{
		myField.value += myValue;
	}
}
function SetValue(dd, value)
{
   for (var i=0; i<dd.options.length; i++)
    if (dd.options[i].value == value)
    {
      dd.selectedIndex = i;
      return;
    }
}
function NewProject(hidden)
{
  var name = prompt("Enter a name for the new client", "NewProject1");
  if (null == name || '' == name)
  {  return false; }
  hidden.value = name;
  return true;		  
}
